class Solution {
public:
    int BinarySearch(vector<int>& data, float k){
        int left = 0, right = data.size()-1;
        while(left <= right){
            int mid = ((right-left)>>1)+left;
            if(data[mid] < k)
                left = mid + 1;
            else if(data[mid] > k)
                right = mid - 1;
        }
        return left;
    }
    
    int GetNumberOfK(vector<int> data ,int k) {
        //分别查找k+0.5和k-0.5应该出现的位置，中间的部分就全是k
        return BinarySearch(data, k + 0.5) - BinarySearch(data, k-0.5);
    }
};